
<template>
  <div class="big">
    <div class="big-box">
      <div class="top-button">
        <div class="top-return" @click.stop="hideBig">
          <span class="icons">
            <i class="icon-fanhui iconfont"></i>
          </span>
        </div>
      </div>
      <div v-if="leftState" class="left-button" @click="handerButtn('left')">
        <i class="icon-zuojiantou iconfont"></i>
      </div>
      <div v-if="rightState" class="right-button" @click="handerButtn('right')">
        <i class="icon-youjiantou iconfont"></i>
      </div>
      <div class="content">
        <div class="imgbox">
          <div class="imgbox-show">
            <div class="img-info" @click.self="hideBig">
              <img :src="currentPic" alt="" :style="{width:'auto',height:childHeight,display: 'block' }" />
            </div>
          </div>
        </div>
        <div class="box-bt">
          <div class="img-hd">
            <div class="hd-box">
              <div
                v-for="(item, i) in plist"
                :class="
                  index === i ? 'img-item avtive_show' : 'img-item'
                "
                :key="i"
                @click="handerPic(i, item.pic)"
              >
                <img :src="item.pic" alt="" />
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 放大图片
export default {
  props: {
    // 接受到的图片数据
    plist: {
      type: Array,
      default: null
    },
    index: {
      type: Number,
      default: 0
    },
    bigShow: {
      type: Boolean,
      default: false
    },
    currentPic: {
      type: String,
      default: ''
    },
    childWidth: {
      type: String,
      default: ''
    },
    childHeight: {
      type: String,
      default: ''
    },
    leftState: {
      type: Boolean,
      default: false
    },
    rightState: {
      type: Boolean,
      default: false
    }

  },
  deta () {
    return {
    }
  },
  created () {},
  mounted () {
    console.log(this.childWidth)
    console.log(this.childHeight)
  },
  watch: {
  },
  methods: {
    // 选项卡选择图片
    handerPic (i, url) {
      console.log(i, url)
      this.$emit('choiceevent', { childI: i, url })
    },
    // 点击返回箭头 隐藏组件
    hideBig () {
      this.$emit('hidechevent')
    },
    handerButtn (val) {
      this.$emit('switchevent', { val: val, childI: this.index })
    }
  }
}
</script>

<style lang="scss" scoped>
.avtive_show {
  border: 4px solid #f60 !important;
}
.big {
  position: fixed;
  z-index: 999;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.2);
  top: 0;
  left: 0;
  .big-box {
    width: 100%;
    height: 100% ;
    position: relative;

    .top-button {
      width: 100%;
      position: relative;
      .top-return {
        position: absolute;
        z-index: 1001;
        cursor: pointer;
        top: 30px;
        left: 30px;
        width: 40px;
        height: 40px;
        background: rgba($color: #000000, $alpha: 0.4);
        border-radius: 50%;
        text-align: center;
        &:hover{
          background: rgba($color: #000000, $alpha: 0.6);
        }
        .icons {
          height: 100%;
          display: block;
          i {
            display: block;
            color: #fff;
            font-size: 20px;
            padding: 10px;
          }
        }
      }
    }
    .left-button{
      z-index: 1004;
      position: absolute;
      top: 50%;
      left: 5%;
      transform: translate(-5%,-50%);
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: rgba($color: #000000, $alpha: 0.4);
      display: flex;
      justify-content: flex-start;
      cursor: pointer;
       &:hover{
          background: rgba($color: #000000, $alpha: 0.6);
        }
      i{
        color: white;
        font-size: 42px;
        margin:  0 2px;
      }
    }
    .right-button{
      z-index: 1004;
      position: absolute;
      top: 50%;
      right:  5%;
      transform: translate(-5%,-50%);
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: rgba($color: #000000, $alpha: 0.4);
      display: flex;
      justify-content:flex-end;
      cursor: pointer;
       &:hover{
          background: rgba($color: #000000, $alpha: 0.6);
        }
      i{
        color: white;
        font-size: 42px;
        margin:  0 2px;
      }
    }
    .content {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      .imgbox {
        width: 100%;
        height: 85%;
        .imgbox-show {
          width: 100%;
          height: 100%;
          position: relative;
          background: rgba($color: #000000, $alpha: 0.4);
          .img-info {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
          img {
            z-index: 1003;
            display: block;
            margin: auto;
          }
        }
        }

      }
      .box-bt {
        width: 100%;
        height: 15%;
        background: #000;

        .img-hd {
          width: 100%;
          height: 100%;
          position: relative;
          .hd-box {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            // width: 60%;
            display: flex;
            margin: 0 auto;
            .img-item {
              width: 50px;
              height: 50px;
              display: inline-block;
              margin: 0 5px;
              border: 4px solid #000;
              cursor: pointer;
              transition: all 0.3s;
              &:hover {
                border: 4px solid #f60;
              }
              text-align: center;
              img {
                width: 100%;
                height: 100%;
                display: block;
              }
            }
          }
        }
      }
    }
  }
}
@media screen and (max-width:540px) {
  .big {
  position: fixed;
  z-index: 2000;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.2);
  top: 0;
  left: 0;
  .big-box {
    width: 100%;
    height: 100% ;
    position: relative;

    .top-button {
      width: 100%;
      position: relative;
      .top-return {
        position: absolute;
        z-index: 1001;
        cursor: pointer;
        top: 0.6rem;
        left: 0.6rem;
        width: 0.9rem;
        height: 0.9rem;
        background: rgba($color: #000000, $alpha: 0.4);
        border-radius: 50%;
        text-align: center;
        &:hover{
          background: rgba($color: #000000, $alpha: 0.6);
        }
        .icons {
          height: 100%;
          display: block;
          i {
            display: block;
            color: #fff;
            font-size: .2rem;
            padding: 10px;
          }
        }
      }
    }
    .left-button{
      z-index: 1004;
      position: absolute;
      top: 50%;
      left: 5%;
      transform: translate(-5%,-50%);
      width: .9rem;
      height: .9rem;
      border-radius: 50%;
      background: rgba($color: #000000, $alpha: 0.4);
      display: flex;
      justify-content: flex-start;
      cursor: pointer;
       &:hover{
          background: rgba($color: #000000, $alpha: 0.6);
        }
      i{
        color: white;
        font-size: .7rem;
        margin:  0 2px;
      }
    }
    .right-button{
      z-index: 1004;
      position: absolute;
      top: 50%;
      right:  5%;
      transform: translate(-5%,-50%);
      width: .9rem;
      height: .9rem;
      border-radius: 50%;
      background: rgba($color: #000000, $alpha: 0.4);
      display: flex;
      justify-content:flex-end;
      cursor: pointer;
       &:hover{
          background: rgba($color: #000000, $alpha: 0.6);
        }
      i{
        color: white;
        font-size: .7rem;
        margin:  0 2px;
      }
    }
    .content {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      .imgbox {
        width: 100%;
        height: 85%;
        .imgbox-show {
          width: 100%;
          height: 100%;
          position: relative;
          background: rgba($color: #000000, $alpha: 0.4);
          .img-info {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
          img {
            z-index: 1003;
            display: block;
            margin: auto;
            width: 100% !important;
            height: auto !important;
          }
        }
        }

      }
      .box-bt {
        width: 100%;
        height: 15%;
        background: #000;

        .img-hd {
          width: 100%;
          height: 100%;
          position: relative;
          .hd-box {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            // width: 60%;
            display: flex;
            margin: 0 auto;
            .img-item {
              width: 1.3rem;
              height: 1.3rem;
              display: inline-block;
              margin: 0 0.16rem;
              border: 4px solid #000;
              cursor: pointer;
              transition: all 0.3s;
              &:hover {
                border: 4px solid #f60;
              }
              text-align: center;
              img {
                width: 100%;
                height: 100%;
                display: block;
              }
            }
          }
        }
      }
    }
  }
}
}
</style>
